package com.visikard.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.EditText;

public class EditView extends EditText {
	private EditViewKeyPreImeListener editViewKeyPreImeListener = null;

	public EditView(Context context) {
		super(context);
	}

	public EditView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public EditView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public void setKeyPreImeListener(EditViewKeyPreImeListener listener) {
		editViewKeyPreImeListener = listener;
	}

	@Override
	public boolean onKeyPreIme(int keyCode, KeyEvent event) {

		if (editViewKeyPreImeListener != null) {
			boolean result = editViewKeyPreImeListener.onKeyPreIme(keyCode, event);
			if (result){
				return true;
			}
		}
		
		// continue if the listener return false
		return super.onKeyPreIme(keyCode, event);
	}

	public interface EditViewKeyPreImeListener {

		boolean onKeyPreIme(int keyCode, KeyEvent event);

	}

}
